﻿using Microsoft.EntityFrameworkCore;
using Payment.API.Infrastructure;
using Payment.API.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Payment.API.Application.Repositories
{
    public class PaymentRepository : IPaymentRepository
    {
        private readonly PaymentContext _context;

        public PaymentRepository(PaymentContext context)
        {
            _context = context;
        }
        public async Task<PaymentLog> GetAsync(int locationId)
        {
            return await _context.FindAsync<PaymentLog>(locationId);
        }

        public async Task<IEnumerable<PaymentLog>> GetPaymentLogListAsync()
        {
            return await _context.PaymentLogs.ToListAsync();
        }

        public async Task AddPaymentLogAsync(PaymentLog paymentLog)
        {
            await _context.PaymentLogs.AddAsync(paymentLog);
            //return await _context.SaveChangesAsync() > 0;
        }

        public Task UpdatePaymentLogAsync(PaymentLog paymentLog)
        {
             _context.PaymentLogs.Update(paymentLog);
            return Task.CompletedTask;
            //return await _context.SaveChangesAsync() > 0;
        }
    }
}
